// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.jasmin.unit.gate;

import com.dustedpixels.jasmin.unit.Unit;

/**
 * NAND combined from AND and NOT.
 * 
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class NANDCombo implements Unit {
  public boolean IN1 = false;
  public boolean IN2 = false;
  public boolean OUT = false;
  
  private final AND andUnit;
  private final NOT notUnit;

  public NANDCombo() {
    this.andUnit = new AND();
    this.notUnit = new NOT();
  }

  public void updateEndPoints() {
    andUnit.IN1 = IN1;
    andUnit.IN2 = IN2;
    andUnit.updateEndPoints();
    
    notUnit.IN = andUnit.OUT;
    notUnit.updateEndPoints();
    
    OUT = notUnit.OUT;
  }
}
